﻿
@using Star.Web
@using WikeSoft.Core.Extension

@using WikeSoft.Enterprise.Interfaces.Sys
@using WikeSoft.Web
@model IList<WikeSoft.Enterprise.Models.Sys.PageModel>
@{
    var pageService = DependencyResolver.Current.GetService<IPageService>();
    var Model = pageService.GetPagesByUserId(HttpContext.Current.User.Identity.GetLoginUserId());

    var topPages = Model.Where(x => x.ParentId == null || x.ParentId == string.Empty).ToList();
}
<script type="text/javascript">
            try { ace.settings.loadState('main-container') } catch (e) { }
</script>

<!-- #section:basics/sidebar -->
<div id="sidebar" class="sidebar responsive ace-save-state">
    <script type="text/javascript">
        try { ace.settings.loadState('sidebar') } catch (e) { }

 
    </script>

    <div class="sidebar-shortcuts" id="sidebar-shortcuts">
        <div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
            <button class="btn btn-success">
                <i class="ace-icon fa fa-signal"></i>
            </button>

            <button class="btn btn-info">
                <i class="ace-icon fa fa-pencil"></i>
            </button>

            <!-- #section:basics/sidebar.layout.shortcuts -->
            <button class="btn btn-warning">
                <i class="ace-icon fa fa-users"></i>
            </button>

            <button class="btn btn-danger">
                <i class="ace-icon fa fa-cogs"></i>
            </button>

            <!-- /section:basics/sidebar.layout.shortcuts -->
        </div>

        <div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
            <span class="btn btn-success"></span>

            <span class="btn btn-info"></span>

            <span class="btn btn-warning"></span>

            <span class="btn btn-danger"></span>
        </div>
    </div><!-- /.sidebar-shortcuts -->

    <ul class="nav nav-list">
        @if (topPages.AnyOne())
        {
            foreach (var topPage in topPages)
            {
                var secondPages = Model.Where(x => x.ParentId == topPage.Id).ToList();
               
                <li class="">
                    <a href="@topPage.PagePath" class="dropdown-toggle">
                        <i class="menu-icon fa @topPage.CssName"></i>
                        <span class="menu-text"> @topPage.PageName </span>

                        <b class="arrow fa fa-angle-down"></b>
                    </a>

                    <b class="arrow"></b>
                    @if (secondPages.AnyOne())
                    {
                        <ul class="submenu">
                            @foreach (var secondPage in secondPages)
                            {
                                var thirdPages = Model.Where(x => x.ParentId == secondPage.Id).ToList();

                                if (!thirdPages.AnyOne())
                                {
                                    <li class="">
                                        <a href="#" targetlink="@secondPage.PagePath">
                                            <i class="menu-icon fa fa-caret-right"></i>
                                            @secondPage.PageName
                                        </a>

                                        <b class="arrow"></b>
                                    </li>
                                }
                                else
                                {
                                    <li class="">
                                        <a href="#" targetlink="@secondPage.PagePath" class="dropdown-toggle">
                                            <i class="menu-icon fa fa-caret-right"></i>

                                            @secondPage.PageName
                                            <b class="arrow fa fa-angle-down"></b>
                                        </a>
                                        <b class="arrow"></b>

                                        <ul class="submenu">
                                            @foreach (var thirdPage in thirdPages)
                                            {
                                                <li class="">
                                                    <a href="#" targetlink="@thirdPage.PagePath">
                                                        <i class="menu-icon"></i>
                                                       @thirdPage.PageName
                                                    </a>

                                                    <b class="arrow"></b>
                                                </li>
                                            }
                                           
                                            


                                        </ul>
                                    </li>
                                }


                            }
                        </ul>
                    }

                </li>
            }
        }
 
        

 
    </ul><!-- /.nav-list -->
    <!-- #section:basics/sidebar.layout.minimize -->
    <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
        <i id="sidebar-toggle-icon" class="ace-icon fa fa-angle-double-left ace-save-state" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
    </div>

    <!-- /section:basics/sidebar.layout.minimize -->
</div>